import request from './request'

/**
 * 获取目录列表
 * @param {*} params
 * @returns
 */
export const getCatalogList = (params) => {
  return request({
    url: '/catalog/list',
    params
  })
}

/**
 * 新增目录
 * @param {*} data
 * @returns
 */
export const addCatalog = (data) => {
  return request({
    url: '/catalog/add',
    method: 'post',
    data
  })
}

/**
 * 修改目录
 * @param {*} data
 * @returns
 */
export const updateCatalog = (data) => {
  return request({
    url: '/catalog/update',
    method: 'put',
    data
  })
}

/**
 * 根据Id删除目录
 * @param {*} id
 */
export const deleteCatalog = (id) => {
  return request({
    url: `/catalog/${id}`,
    method: 'delete'
  })
}

/**
 * 根据目录Id查询分类列表
 * @param {*} id 
 * @returns 
 */
export const getcatalogSortList = (id) => {
  return request({
    url: `/catalogSort/list/${id}`,
  })
}

/**
 * 新增目录关联分类
 * @param {*} data 
 * @returns 
 */
export const addCatalogSort = (data) => {
  return request({
    url: '/catalogSort/add',
    method: 'post',
    data
  })
}

/**
 * 根据Id删除目录关联分类
 * @param {*} catalog_id 
 * @param {*} sort_id 
 * @returns 
 */
export const deleteCatalogSort = (catalog_id, sort_id) => {
  return request({
    url: `catalogSort/delete`,
    method: 'post',
    data: {
      catalog_id, sort_id
    }
  })
}